package com.shuzi.MediaShare.view;

import android.graphics.Bitmap;
import android.view.animation.AlphaAnimation;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.display.BitmapDisplayer;

/**
 * 自定义图片加载完成后显示动画
 * 
 * @author lung
 * 上午12:40:20
 * 2013
 */
public class FadeAnimation implements BitmapDisplayer
{
	
	private final int durationMillis;

	public FadeAnimation(int durationMillis) {
		this.durationMillis = durationMillis;
	}

	@Override
	public Bitmap display(Bitmap bitmap, ImageView imageView)
	{
		imageView.setImageBitmap(bitmap);

		animate(imageView, durationMillis);

		return bitmap;
	}
	
	public static void animate(ImageView imageView, int durationMillis) {
		AlphaAnimation fadeImage = new AlphaAnimation(0.1f, 1);
		fadeImage.setDuration(durationMillis);
		imageView.startAnimation(fadeImage);
	}

}
